<?php

class AttributeProcessor {
	
	var $__class;
	var $__method;
	var $__attributes = array();
	
	public function __construct($class, $method) {
		
		$method = new ReflectionMethod($class, $method);
		$attributes = $method->getDocComment();
		
		preg_match_all('/\"(.*):(.*)\"/', $attributes , $result, PREG_PATTERN_ORDER);	
		
		if (count($result) > 0) {
			for ($i = 0; $i < count($result[1]); $i++) {
				$tmp = str_replace("_", " ", $result[1][$i]);
				$this->__attributes[StringUtils::strToCamel($tmp)] = trim($result[2][$i]);
			}
		}
	}
	
	public function hasAttributes() {
		return count($this->__attributes) > 0;
	}
	
	public function process() {
		$result = false;
		foreach ($this->__attributes as $key => $value) {
			$attribute = ClassLoader::load($key . 'Attribute', $value);
			$result = $attribute->process();
		}
		return $result;
	}
}

?>